package com.yc.shadowdemo

import com.yc.commontlib.extension.ycLogE
import com.yc.commontlib.extension.ycLogESimple
import com.yc.commontlib.net.YcRetrofitUtil
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Query

/**
 * Creator: yc
 * Date: 2021/6/7 14:17
 * UseDes:
 */
class HostTest {
    interface ApiService {
        /**
         * 版本更新
         */
        @GET("clientPackage/getClientVersion")
        suspend fun getVersion(
            @Query("clientType") clientType: String = "1",
            @Query("channel") channel: String = "com.hc.hcc",
            @Header("other_base_url") otherUrl: String = "http://update.jsqqy.com:8081/",
        ): String
    }

    companion object {
        fun getVersionData() {
            ycLogESimple("start")
            try {
                GlobalScope.launch {
                    try {
                        val json = YcRetrofitUtil.Instance.getApiService(ApiService::class.java).getVersion()
                        ycLogE(json)
                    } catch (e: Exception) {
                        e.printStackTrace()
                        ycLogESimple(e.message)
                    }
                }
            } catch (e: Exception) {
                e.printStackTrace()
                ycLogESimple(e.message)
            }
        }
    }
}